RowTop Method Example

This example begins a drag operation in the grid. Using the grid cell location and size properties, a Label control the size of the cell is used as the drag object.

Sub DataGrid1_MouseDown (Button As Integer, _
Shift As Integer, X As Single, Y As Single)
   ' Declare variables.
   Dim DY, DX, RowValue, ColValue, CellLeft, CellTop
 ColValue = DataGrid1.ColContaining(X)
 RowValue = DataGrid1.RowContaining(Y)
   ' Get the height of the cell.
 DY = DataGrid1.RowHeight  
   ' Get the width of the cell.
 DX = DataGrid1.Columns(ColValue).Width  
   CellLeft = DataGrid1.Columns(ColValue).Left
 CellTop = DataGrid1.RowTop(RowValue)
 Label1.Caption = DataGrid1.Columns(ColValue). _
      CellValue(DataGrid1.RowBookmark(RowValue))
 Label1.Move CellLeft, CellTop, DX, DY
 Label1.Drag ' Drag label outline.
End Sub